package com.example.redisstudy;

public class InsuranceValidator {
    
    // 定义代理人的等级
    private static final int AGENT_LEVEL_1 = 1;
    private static final int AGENT_LEVEL_2 = 2;
    private static final int AGENT_LEVEL_3 = 3;
    private static final int AGENT_LEVEL_4 = 4;
    
    // 判断代理人的执业等级是否支持购买当前投保险种
    public static boolean isInsuranceAvailable(int agentLevel, int insuranceLevel) {
        // 根据代理人等级判断支持的投保险种
        switch (agentLevel) {
            case AGENT_LEVEL_1:
                return insuranceLevel >= 1 && insuranceLevel <= 4;
            case AGENT_LEVEL_2:
                return insuranceLevel >= 1 && insuranceLevel <= 3;
            case AGENT_LEVEL_3:
                return insuranceLevel >= 1 && insuranceLevel <= 2;
            case AGENT_LEVEL_4:
                return insuranceLevel == 1;
            default:
                return false; // 未知的代理人等级，返回false
        }
    }
    
    public static void main(String[] args) {
        // 示例：代理人等级为2，投保险种等级为3
        int agentLevel = 1;
        int insuranceLevel = 2;
        
        // 判断代理人的执业等级是否支持购买当前投保险种
        boolean isAvailable = isInsuranceAvailable(agentLevel, insuranceLevel);
        System.out.println("Insurance is available for agent level " + agentLevel + " and insurance level " + insuranceLevel + ": " + isAvailable);
    }
}
